package com.jar.netty_demo.Netty.dubbo.netty;

import com.jar.netty_demo.Netty.dubbo.producer.HelloServiceImpl;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class NettyServerHandle extends ChannelInboundHandlerAdapter {
    /**
     * 根据协议头获取bean,然后反向代理调用其方法
     */
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        System.out.println("收到客户端的消息:" + msg);
        HelloServiceImpl helloService = new HelloServiceImpl();
        String message = helloService.say("服务器主动创建service");
        ctx.writeAndFlush(message);
    }

}
